import axios from 'axios';

const api = axios.create({
  baseURL: process.env.REACT_APP_API_BASE,
  headers: {
    'Authorization': `Bearer ${process.env.REACT_APP_API_KEY}`,
    'Content-Type': 'application/json'
  }
});

export const chatService = {
  sendMessage: async (payload: ChatRequest): Promise<APIResponse<ChatResponse>> => {
    try {
      const response = await api.post('/chat/completion', payload);
      return response.data;
    } catch (error) {
      throw new Error('API请求失败');
    }
  }
};
